/*
	rectModel
	The object for the rect which will be the player.
	
	possible args:
	radius:double
	latNum:int
	lonNum:int
*/
function RectModel (height, width, depth){
	setDefaults(this);

	this.depth = depth;
	
	var rectColorData = [];
	this.color = [0.4, 0.6, 0.1, 1.0];
	
	this.create = function(){
        var depth = this.depth;
		this.vertexData = [  // Vertices of the 6 faces
			// Back
			0, -height,  -depth, // left - bottom - front   
			width, -height,  -depth, // right - bottom - front
			0,  0,  -depth, // left - top - front
			width,  0,  -depth, // right - top - front
			 
			//Top
			width,  0,  -depth,
			width,  0,  depth,
			0,  0,  -depth,
			0,  0,  depth,
			 
			//Left
			0,  0,  -depth,
			0,  0,  depth,
			0,  -height,  -depth,
			0,  -height,  depth,
			 
			//Right
			width,  -height,  -depth,
			width,  -height,  depth,
			width,  0,  -depth,
			width,  0,  depth,
			 
			//Bottom
			width,  -height,  depth,
			width, -height, -depth,
			0, -height,  depth,
			0,  -height,  -depth,

			 //Front 
			width,  -height,  depth, // right - bottom - ront
			0,  -height,  depth, // let - bottom - ront  
			width,  0,  depth, // right - top - ront
			0,  0,  depth, // let - top - ront
			
		];
		
		// texture stuff
		
		faceVertexTextureCoordBuffer = gl.createBuffer();  
		gl.bindBuffer(gl.ARRAY_BUFFER, faceVertexTextureCoordBuffer);  
  
		this.extraVertexData = [
		
			0, 0, 0,
			0, 0, 0,
			0, 0, 0,
			
			0, 0, 0,
			0, 0, 0,
			0, 0, 0,

			0, 0, 0,
			0, 0, 0,
			0, 0, 0,

			0, 0, 0,
			0, 0, 0,
			0, 0, 0,

			0, 0, 0,
			0, 0, 0,
			0, 0, 0,

			//Front 
			width,  -height,  depth, // right - bottom - ront
			0,  -height,  depth, // let - bottom - ront  
			width,  0,  depth, // right - top - ront
			0,  0,  depth, // let - top - ront
		];
		
		gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(this.vertexData), gl.STATIC_DRAW);  
		
        // end texture stuff
		
		this.normalData = [];
        for (var i = 0; i < 4; i++) {
            this.normalData.push(0, 0, -1);
        }
        for (var i = 0; i < 4; i++) {
            this.normalData.push(0, 1, 0);
        }
        for (var i = 0; i < 4; i++) {
            this.normalData.push(-1, 0, 0);
        }
        for (var i = 0; i < 4; i++) {
            this.normalData.push(1, 0, 0);
        }
        for (var i = 0; i < 4; i++) {
            this.normalData.push(0, -1, 0);
        }
        for (var i = 0; i < 4; i++) {
            this.normalData.push(0, 0, 1);
        }
	}
	
    this.draw = function(camera) {
		this.prepareDraw(camera);
		for(var face = 0; face < 6; face++){
			gl.drawArrays(gl.TRIANGLE_STRIP, face * 4, 4);
		}
    }

    this.create();
    this.initBuffers();
}
